#ifndef PSQLENUMDELEGATE_H
#define PSQLENUMDELEGATE_H

#include <QItemDelegate>

class QSqlDatabase;
class QSqlQueryModel;
class QSqlTableModel;

class mRelationModel
{
public:
    mRelationModel(QSqlTableModel *theModel, QString theKey, QString theDisplay)
    {
        model_=theModel;
        key_ = theKey;
        display_ = theDisplay;
    }
    QSqlTableModel *model(){return model_;}
    QString key(){return key_;}
    QString display(){return display_;}
private:
    QSqlTableModel *model_;
    QString key_;
    QString display_;
};

class psqlenumdelegate: public QItemDelegate
{
public:
    psqlenumdelegate(QString tableName, QSqlDatabase db = QSqlDatabase(), QObject *parent = 0);
    //~psqlenumdelegate();
    QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const;
    void setEditorData(QWidget *editor, const QModelIndex &index) const;
    void setModelData(QWidget *editor, QAbstractItemModel *model, const QModelIndex &index) const;
private:
    QMap<QString, QSqlQueryModel*> enums;//Модели для перечислений
    QMap<QString, mRelationModel*> fcs;//Модели для отношений классов
};

#endif // PSQLENUMDELEGATE_H
